package com.skymxc.demo.explorer.core;

import java.io.File;

/**
 * Created by sky-mxc
 * 文件类型
 */

public enum  FileType {
    UNKNOW,
    DIR,
    FILE,
    DATABASE,
    EXL,
    ZIP,
    IMAGE,
    AUDIO,
    VIDEO,
    PDF,
    PPT,
    PSD,
    TEXT,
    WORD;

    public static FileType parseFile(File file){
        if (file.isDirectory()){
            return  DIR;
        }else{
            String name = file.getName();
            if (name.endsWith(".db")){
                return  DATABASE;
            }else if ( name.endsWith(".xls")||name.endsWith(".xlsx")){
                return  EXL;
            }else if (name.endsWith(".pot")|| name.endsWith(".potx")){
                return  PPT;
            }else if (name.endsWith(".zip")){
                return  ZIP;
            }else if (name.endsWith(".png")||name.endsWith(".jpg")||name.endsWith(".jpeg")){
                return IMAGE;
            }else if (name.endsWith(".mp3")){
                return  AUDIO;
            }else if (name.endsWith(".mp4")){
                return  VIDEO;
            }else if(name.endsWith(".pdf")){
                return PDF;
            }else if (name.endsWith(".psd")){
                return PSD;
            }else if (name.endsWith(".txt")){
                return TEXT;
            }else if(name.endsWith(".cod")||name.endsWith(".docx")){
                return WORD;
            }else{
                return  UNKNOW;
            }
        }
    }
}
